﻿/*
Copyright (C) 2009  Tomasz Chrzanowski

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;


namespace Com.TomCdc.ChangeDataCapture
{
    [RunInstallerAttribute(true)]
    public class CdcProcessorServiceInstaller:Installer
    {
        /// <summary>
        /// The service friendly name.
        /// </summary>
        private const string SERVICE_FRIENDLY_NAME = "Change Data Capture Agent";

        /// <summary>
        /// The service description.
        /// </summary>
        private const string SERVICE_DESCRIPTION = "Performs processing of the captured changed data of monitored system.";

        /// <summary>
        /// Installers objects.
        /// </summary>
        private ServiceProcessInstaller serviceProcInst;
        private ServiceInstaller serviceInst;

        public CdcProcessorServiceInstaller()
        {
            // Instantiates installers for the process and service.
            serviceProcInst = new ServiceProcessInstaller();
            serviceInst = new ServiceInstaller();

            // configures service process installer
            serviceProcInst.Account = ServiceAccount.LocalService;

            // configures service installer
            serviceInst.StartType = ServiceStartMode.Manual;
            serviceInst.ServiceName = CommonHelper.CDC_AGENT_SERVICE_NAME;
            serviceInst.DisplayName = SERVICE_FRIENDLY_NAME;
            serviceInst.Description = SERVICE_DESCRIPTION;

            // addeds instances do installers collection
            Installers.Add(serviceProcInst);
            Installers.Add(serviceInst);
        }

    }
}
